{include file="public/header" /}

<body style="background-color: #ffffff">
    <div class="layui-fluid">
        <div class="layui-row">
            <form class="layui-form">
                <div class="layui-form-item">
                    <label for="L_choose_name" class="layui-form-label">
                        <span class="x-red">*</span>分类名称</label>
                    <div class="layui-input-inline">
                        <input type="text" id="name" name="name" required="" lay-verify="required" autocomplete="off"
                            class="layui-input" value="{$row.name|default=''}" placeholder="请输入选择名称">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_choose_name" class="layui-form-label">
                        <span class="x-red">*</span>分类名称备注</label>
                    <div class="layui-input-inline">
                        <input type="text" id="remark" name="remark" required="" lay-verify="required"
                            autocomplete="off" class="layui-input" value="{$row.remark|default=''}"
                            placeholder="请输入选择名称">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_choose_name" class="layui-form-label">
                        <span class="x-red">*</span>所属商家</label>
                    <div class="layui-input-inline">
                        <select name="shopid" lay-verify="" lay-search=''>
                            <option value="">输入名称快速查找</option>
                            {foreach $shoplist as $v}
                            <option value="{$v.id}" {if !empty($row.shopid) && $row.shopid==$v.id}selected{/if}>
                                {$v.title|default=''}(账号:{$v.account|default=''})</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_choose_name" class="layui-form-label">
                        <span class="x-red">*</span>排序[数值越大靠前]</label>
                    <div class="layui-input-inline">
                        <input type="number" id="sorts" name="sorts" required="" lay-verify="required"
                            autocomplete="off" class="layui-input" value="{$row.sorts|default='0'}" placeholder="请输入排序">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_choose_name" class="layui-form-label">
                        是否显示</label>
                    <div class="layui-input-inline">
                        <select name="ishow" lay-verify="required" lay-filter="type">
                            <option value="1" {if !empty($row.ishow) && $row.ishow==1}selected{/if}>显示</option>
                            <option value="2" {if !empty($row.ishow) && $row.ishow==2}selected{/if}>隐藏</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_choose_name" class="layui-form-label">
                        是否热门</label>
                    <div class="layui-input-inline">
                        <select name="ishot" lay-verify="required" lay-filter="type">
                            <option value="1" {if !empty($row.ishot) && $row.ishot==1}selected{/if}>是</option>
                            <option value="2" {if !empty($row.ishot) && $row.ishot==2}selected{/if}>否</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"></label>
                    <input type="hidden" value="{$row.id|default=''}" name="id">
                    <button class="layui-btn  layui-btn-normal" lay-filter="add" lay-submit="">提交</button>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <button type="button" class="layui-btn layui-btn-danger" onclick="IframeClose()">取消</button>
                </div>
            </form>
        </div>
    </div>

    {include file="public/footer" /}
    <script src="/static/leyedit/Layui-KnifeZ/layui.js"></script>
    <script src="/static/leyedit/ace/ace.js"></script>
    <script>
        layui.use(['layedit', 'layer', 'jquery', 'form'], function () {
            $ = layui.jquery;
            var form = layui.form
                , upload = layui.upload
                , layer = layui.layer;
            var layedit = layui.layedit;
            //监听提交
            form.on('submit(add)', function (data) {
                $.ajax({
                    'type': 'post',
                    data: data.field,
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, { icon: 6, time: 1000 }, function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.location.reload();
                                parent.layer.close(index);
                            });
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                });
                return false;
            });
        });
    </script>

</body>

</html>